<template>
  <div class="fold-wrap" ref="fold" v-if="list && list.length > 3">
    <div v-show="flag" @click="_open(0)">
      展开全部 <span class="mui-icon mui-icon-arrowdown"></span>
    </div>
    <div v-show="!flag" @click="_open(1)">
      收起 <span class="mui-icon  mui-icon-arrowup"></span>
    </div>
  </div>
</template>

<script>
  import {togClass} from "../js/common.js"
  export default {
    props: {
      list: {
        default: []
      }
    },
    data(){
      return {
        flag: 1
      }
    },
    methods: {
      _open(v){
        this.flag = v;
        let arr = this.$refs.fold.parentNode.childNodes[2].children;
        for (let i = 0; i < arr.length; i++) {
          togClass(arr[i], "fold-hide");
        }
      },
    }
  }
</script>

<style lang="scss">
  .fold-wrap {
    height: 30px;
    line-height: 30px;
    text-align: center;
    color: #676767;
    font-size: 13px;
    background-color: #fff;
    .mui-icon {
      font-size: 16px;
    }
  }
</style>
